interface Alpha {}
interface Beta {}

interface HelloMapping {
  'Alpha': Alpha
  'Beta': Beta  
}

const hello = <T extends keyof HelloMapping>(arg: T): HelloMapping[T] => 
{
  if (arg === 'Alpha') return {} as Alpha;
  return {} as Beta;
};

const aa = hello('Alpha') // a is of interface Alpha



interface HelloMapping2 {
  'Alpha1': string
  'Beta1': number
}

const helloAssert = <T extends keyof HelloMapping2>(arg: T): HelloMapping2[T] => {
  if (arg === 'Alpha1') {
      return "42" as HelloMapping2[T];
  }
  return 42 as HelloMapping2[T];
};

function helloOverload<T extends keyof HelloMapping2>(arg: T): HelloMapping2[T];
function helloOverload(arg: keyof HelloMapping2) {
  if (arg === 'Alpha1') {
      return "42"
  }
  return 42;
}

const helloMap = <T extends keyof HelloMapping2>(arg: T): HelloMapping2[T] =>
  ({ Alpha1: "42", Beta1: 42 })[arg];
